package com.inexas.cu.client.pipe;

import com.google.gwt.event.shared.*;
import com.google.gwt.user.client.rpc.*;

public class RequestEvent<R extends AbstractRequest> extends GwtEvent<RequestHandler<R>>
implements IsSerializable{
	private final R request;

	public RequestEvent(R request) {
		this.request = request;
	}

	public R getRequest() {
		return request;
	}
	
	@Override
	protected void dispatch(RequestHandler<R> handler) {
		handler.onFired(this);
	}

	@SuppressWarnings("unchecked")
    @Override
    public  GwtEvent.Type<RequestHandler<R>> getAssociatedType() {
		final Object type = request.getAssociatedType();
		return (GwtEvent.Type<RequestHandler<R>>)type;
    }

}
